package com.zhengxing.jienci.stream.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

/**
 * @author 浪遏飞舟
 * @create 2020-09-23 11:24
 */
@Component
@EnableBinding({Sink.class,Sink1.class}) //Sink类的INPUT注解里面的值表示监听那个通道
public class ReceiveMessageListenerController {

    @Value("${server.port}")
    private String serverPort;


    @StreamListener("input") //注解的值表明监听那个通道
    public void input(Message<String> message)
    {
        System.out.println(message.getPayload());
        System.out.println("消费者1号,----->接受到input通道的消息: "+message.getPayload()+"\t  port: "+serverPort);
    }

    @StreamListener("input1")
    public void input1(Message<String> message)
    {
        System.out.println(message.getPayload());
        System.out.println("消费者1号,----->接受到input1通道的消息: "+message.getPayload()+"\t  port: "+serverPort);
    }


}
